<?php
// 我的红包

namespace app\shop\controller;

use think\Session;
use think\Request;
use think\Controller;
use app\shop\model\GoodsType as GoodsTypeModel;
use app\shop\model\RedPacket as RedPacketModel;
use app\shop\model\MemberPacket as MemberPacketModel;

class MemberPacket extends Controller
{
    public function index(Request $request, MemberPacketModel $memberPackets, GoodsTypeModel $goodsType)
    {
        // 获取参数
        $inquire = $request->param();
        $member_id = Session::get('member_id');

        //红包列表
        $data = $memberPackets->where('member_id', $member_id)->paginate(10, false, ['query' => $inquire]);

        // 获取商品分类信息
        $type_arr = $goodsType->where(['status' => 1])->field('id,parenTid,title')->select();
        $menu = get_cate($type_arr);


        return $this->fetch('', [
            'mate_head' => '我的红包',
            'menu'      => $menu,
            'data'      => $data
        ]);
    }
}